package com.isorf.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.isorf.mapper.BrandMapper;
import com.isorf.pojo.Brand;
import com.isorf.service.BrandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BrandServiceImpl implements BrandService {
    @Autowired
    private BrandMapper brandMapper;

    @Override
    public Boolean addBrand(Brand brand) {
        int result = brandMapper.addBrand(brand);
        return result > 0;
    }

    @Override
    public Boolean deleteBrand(int brandId) {
        int result = brandMapper.deleteBrand(brandId);
        return result > 0;
    }

    @Override
    public Boolean updateBrand(Brand brand) {
        int result = brandMapper.updateBrand(brand);
        return result > 0;
    }

    @Override
    public Brand getBrandById(int brandId) {
        return brandMapper.getBrandById(brandId);
    }

    @Override
    public PageInfo<Brand> pageList(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Brand> list = brandMapper.getAllBrands();
        return new PageInfo<>(list);
    }

    @Override
    public List<Brand> getAllBrands() {
        return brandMapper.getAllBrands();
    }
}
